#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define L 800
char m[L][L];
struct P
{
	double x, y;
	P(double x=0, double y=0): x(x), y(y) {}
};
P operator +(P a, P b) { return P(a.x+b.x, a.y+b.y); }
P operator -(P a, P b) { return P(a.x-b.x, a.y-b.y); }
P operator *(P a, double b) { return P(a.x*b, a.y*b); }
void drline(P a, P b, int c)
{
	int x, y;
	if(fabs(a.x-b.x)>fabs(a.y-b.y))
	{
		if(b.x<a.x) swap(a, b);
		for(x=a.x; x<=b.x; y=a.y+(x-a.x)*(b.y-a.y)/(b.x-a.x), m[x][y]=c, x++);
	}
	else
	{
		if(b.y<a.y) swap(a, b);
		for(y=a.y; y<=b.y; x=a.x+(y-a.y)*(b.x-a.x)/(b.y-a.y), m[x][y]=c, y++);
	}
}
void out(int w, int h)
{
	int head[]={66, 77, 54, 48, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, 0, 64, 0, 0, 0, 64, 0, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	int length=54, width=18, height=22;
	int i, j;
	freopen("image.bmp", "wb", stdout);
	head[width]=w%256;
	head[width+1]=w/256;
	head[height]=h%256;
	head[height+1]=h/256;
	for(i=0; i<length; putchar(head[i]), i++);
	for(i=0; i<h; i++)
		for(j=0; j<w; j++)
		{
			putchar(255-m[j][i]);
			putchar(255-m[j][i]);
			putchar(255-m[j][i]);
		}
}
#define N 1010
P a[N][4];
int main()
{
	int n, i, j;
	double k;
	P b, e, p;
	b=P(N*N, N*N);
	e=P(-N*N, -N*N);
	for(scanf("%d", &n), i=0; i<n; a[i][3]=a[i][0], i++)
		for(j=0; j<3; j++)
		{
			scanf("%lf%lf", &p.x, &p.y);
			a[i][j]=p;
			b.x=min(b.x, p.x);
			b.y=min(b.y, p.y);
			e.x=max(e.x, p.x);
			e.y=max(e.y, p.y);
		}
	k=min((L-20.0)/(e.x-b.x), (L-20.0)/(e.y-b.y));
	b=(b+e)*0.5;
	e=P(L/2, L/2);
	for(i=0; i<n; i++)
		for(j=0; j<3; drline(e+(a[i][j]-b)*k, e+(a[i][j+1]-b)*k, 25+(i+1)*230/n), j++);
	out(L, L);
	return 0;
}